/***********************************************************************
* Long-term effects of weather-induced migration on urban labor and housing 
  markets
* Busso & Chauvin

* Purpose: Script execute the build stage of the project

**************************************************************************/

/* First, set the project's directory */
global dir "" // CHANGE THIS!

/* Set the folder structure and macro globals for the project */
do "$dir/build/scripts/settings.do"

/*******************************************************************************
	DROUGHT DATA
*******************************************************************************/
/* Generate drought indicators, indexes and climate variables from other datasets */
do "$db_scr/droughts_index.do"

/* Make the shift share instruments */
do "$db_scr/shift_share_instrument.do"

/* City panel, full dataset and main specification */
do "$db_scr/cities_panel.do"

/* Prepare dataset with outcomes, instruments, endogenous variables, and controls */
do "$db_scr/dataset_preparation.do"

/*******************************************************************************
	ANALYSIS & TABLES
*******************************************************************************/
/* Implement balance tests from Borusyak et al. */
do "$da_scr/balance_covariates.do"

/* Create map of variation in -1*SPEI over the period of analysis */
do "$da_scr/map.do"

/* Rural-level first stage analysis */
do "$db_scr/first_stage_rural_emig.do"

/* All descriptive statistics tables */
do "$da_scr/descriptive_stats_1.do"
do "$da_scr/descriptive_stats_2.do"

/* Run regressions at the rural-area-level */
do "$da_scr/implementation.do"

/* Format nearly all tables and convert them to .tex files. */
do "$da_scr/format_tables.do"
